/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-07-05 15:22:51
 * @LastEditTime : 2023-07-06 11:17:40
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\ProjectInformation.jsx
 * @Description  :
 */

import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { OpenTwoRouter, CommonButton } from '../Common/options'
import { OrganizationIdentityLevel } from '../Common/Conversion'

export const ProjectInformation = async ({ url, OptionsEvent, Permission, actionRef }) => {
    let data = {
        type: '项目管理',
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST([5])[`getOrganizationIdentityLevel`],
        columns: [
            commonTableList.uuid,

            {
                dataIndex: 'selfOrganizationUuid',
                title: '组织机构',
                valueType: 'select',
                valueEnum: await OrganizationIdentityLevel(5),
                width: 300,
                hideInAdded: true,
                hideInModify: true,
                hideInTable: true,
            },
            { ...commonTableList.tableName, title: '项目名称', width: 500, hideInSearch: true },
            { ...commonTableList.code, rules: true, hideInSearch: true },
            { ...commonTableList.sortId, rules: true },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { tableName } = record
                    return [
                        Permission.findIndex(v => v.uuid === '7780ee87-b8ba-448f-a14c-66abb5a8c351') !== -1 && (
                            <OpenTwoRouter
                                key="TwoOne"
                                title="字段配置"
                                twoTitle="子项目字段配置"
                                modal="EditTableModal"
                                OptionsEvent={OptionsEvent}
                                other={{
                                    page: 'ProjectFormItem',
                                    actionRef,
                                    Permission,
                                    oneData: record,
                                    header: data.columns,
                                }}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '2c8cee79-630b-4834-89ed-2ed20447f19b') !== -1 && (
                            <CommonButton
                                key="RichText"
                                OptionsEvent={OptionsEvent}
                                title="数据配置"
                                data={{
                                    smallTitle: `${tableName} 项目数据配置`,
                                    type: 'ProjectFormItemValue',
                                    record,
                                    width: 1500,
                                    Permission,
                                }}
                            />
                        ),
                    ]
                },
            },
        ],
    }

    return data
}
